In [47]:
import numpy
import matplotlib.pyplot
%matplotlib inline
In [48]:
data = numpy.loadtxt(fname='data/weather-01.csv', delimiter=',')
In [49]:
# Create a wide figure to hold the subplots
fig = matplotlib.pyplot.figure (figsize=(10.0,3.0))
# Create Placeholders for the plots
subplot1 = fig.add_subplot (1,3,1)
subplot2 = fig.add_subplot (1,3,2)
subplot3 = fig.add_subplot (1,3,3)
subplot1.set_ylabel('average')
subplot1.plot(numpy.mean(data, axis = 0))
subplot2.set_ylabel('minimum')
subplot2.plot(numpy.min(data, axis = 0))
subplot3.set_ylabel('maximum')
subplot3.plot(numpy.max(data, axis = 0))
fig.tight_layout()
matplotlib.pyplot.show()
In [50]:
word = 'notebook'
print (word[4])
In [51]:
for char in word:
print (char)
In [52]:
# Importing glob
import glob
In [53]:
print (glob.glob('data/weather*.csv'))
In [54]:
filenames = sorted(glob.glob('data/weather*.csv'))
#filenames = filenames[0:12]
for f in filenames:
print (f)
data = numpy.loadtxt(fname=f, delimiter=',')
if numpy.max (data, axis=0) [0] == 0 and numpy.max (data, axis=0)[20] == 20:
print ("Suspicious looking maxima")
elif numpy.sum(numpy.min(data, axis=0)) == 0:
print ("Minima add up to zero")
else:
print ("Data looks OK")
# Create a wide figure to hold the subplots
fig = matplotlib.pyplot.figure (figsize=(10.0,3.0))
# Create Placeholders for the plots
subplot1 = fig.add_subplot (1,3,1)
subplot2 = fig.add_subplot (1,3,2)
subplot3 = fig.add_subplot (1,3,3)
subplot1.set_ylabel('average')
subplot1.plot(numpy.mean(data, axis = 0))
subplot2.set_ylabel('minimum')
subplot2.plot(numpy.min(data, axis = 0))
subplot3.set_ylabel('maximum')
subplot3.plot(numpy.max(data, axis = 0))
fig.tight_layout()
matplotlib.pyplot.show()
In [55]:
num = 101
if num > 100:
print ("Greater")
else:
print ("Not Greater")
print ("Done")
In [56]:
num = 37
if num > 100:
print ("Greater")
else:
print ("Not Greater")
print ("Done")
In [57]:
num = 10
if num > 0:
print (num, "is positive")
elif num == 0:
print (num, "is zero")
else:
print (num, "is negative")
In [58]:
def fahr_to_kelvin(temp):
return ((temp - 32) * (5/9) + 273.15)
In [59]:
print ("Frezzing Point of water:", fahr_to_kelvin(32))
In [60]:
print ("Boiling Point of water:", fahr_to_kelvin(212))
In [65]:
def analyse (filename):
"""This is a function that does analyse the data and does a plot of Graphs"""
data = numpy.loadtxt(fname=filename, delimiter=',')
# Create a wide figure to hold the subplots
fig = matplotlib.pyplot.figure (figsize=(10.0,3.0))
# Create Placeholders for the plots
subplot1 = fig.add_subplot (1,3,1)
subplot2 = fig.add_subplot (1,3,2)
subplot3 = fig.add_subplot (1,3,3)
subplot1.set_ylabel('average')
subplot1.plot(numpy.mean(data, axis = 0))
subplot2.set_ylabel('minimum')
subplot2.plot(numpy.min(data, axis = 0))
subplot3.set_ylabel('maximum')
subplot3.plot(numpy.max(data, axis = 0))
fig.tight_layout()
matplotlib.pyplot.show()
In [63]:
def detect_problems (filename):
"""Some of our temperature files have problems, check for these.
This fucntion reads a file (filename argument) and reports on odd looking maxima and minima
that add up to zero.
This seems to happen when the sensors break.
The function does not return any data. """
data = numpy.loadtxt(fname=filename, delimiter=',')
if numpy.max (data, axis=0) [0] == 0 and numpy.max (data, axis=0)[20] == 20:
print ("Suspicious looking maxima")
elif numpy.sum(numpy.min(data, axis=0)) == 0:
print ("Minima add up to zero")
else:
print ("Data looks OK")
In [ ]:
for f in filenames [0:5]:
print (f)
analyse (f)
detect_problems (f)
In [ ]:
help(numpy.loadtxt)
In [ ]:
# Already written function (detect_problems) does not have any documentation
help(detect_problems)
In [64]:
# Please refer to the comment section in all functions
help(detect_problems)
In [66]:
# Please refer to the comment section in all functions
help(analyse)
In [ ]: